﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PSU.Models
{
    public class RepositorioTipoPersona: IRepositorio<TipoPersona>
    {
        private psuDBDataContext db = new psuDBDataContext();

        public IQueryable<TipoPersona> FindAll()
        {
            return db.TipoPersonas;
        }

        public TipoPersona Get(int id)
        {
            return db.TipoPersonas.SingleOrDefault(d => d.IdTipoPersona == id);
        }

        public void Add(TipoPersona ob)
        {
            db.TipoPersonas.InsertOnSubmit(ob);
        }

        public void Delete(TipoPersona ob)
        {
            db.Personas.DeleteAllOnSubmit(ob.Personas);
            db.TipoPersonas.DeleteOnSubmit(ob);
        }

        public void Save()
        {
            db.SubmitChanges();
        }
    }
}